package com.hq.myvideo;

import android.content.pm.ActivityInfo;
import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.viewpager2.widget.ViewPager2;

import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    StandardGSYVideoPlayer videoPlayer;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main);
        //随系统旋转
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
        //横屏
        //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
/*
       this.player = findViewById(R.id.vp);
        String source1 = "https://m3u8.49cdn.com/newhd/202205/6285df56a4abea1e9312f982/hls/index.m3u8";
        this.player.setUp(source1, true, "测试视频");

        //增加title
      //  this.player.getTitleTextView().setVisibility(View.VISIBLE);
        this.player.setSeekOnStart(833513);
        this.player.startPlayLogic();
        this.player.getDuration();

       new Thread(new Runnable() {
           @Override
           public void run() {
               while(true){
                   Log.d("getCurrentPositionWhenPlaying","当前播放时间 = "+player.getCurrentPositionWhenPlaying());
               }
           }
       }).start();

*/
        List<String> patrh=new ArrayList<>();
        for (int i=0;i<100;i++){
            patrh.add("https://m3u8.49cdn.com/newhd/202205/6285df56a4abea1e9312f982/hls/index.m3u8");
        }
        P2fa ff=new P2fa(this,patrh);
        VideoPagerAdapter vpf=new VideoPagerAdapter(getSupportFragmentManager(),patrh);
        ViewPager2 v22=findViewById(R.id.viewpager2);

        v22.setOrientation(ViewPager2.ORIENTATION_VERTICAL);
        v22.setAdapter(ff);
        //  ViewPager p2=findViewById(R.id.viewpager2);

        //FullPlayerFragment fpf=new FullPlayerFragment();

        // 设置LayoutManager为垂直
        //ViewPager2.ORIENTATION_HORIZONTAL
        // p2.setOrientation(ViewPager2.ORIENTATION_VERTICAL);
        //  p2.setAdapter(vpf);

    }
}
